package com.youhui.weixin.controller.upload;

import org.apache.tomcat.util.http.fileupload.ProgressListener;

import javax.servlet.http.HttpSession;

/**
 * Created by https://github.com/kuangcp on 17-10-7  下午8:50
 */
public class FileUploadProgressListener implements ProgressListener {
    private HttpSession session;
    public FileUploadProgressListener(HttpSession session) {
        this.session = session;
    }
    //pBytesRead  已经上传的大小
    //pContentLength   文件总大小
    @Override
    public void update(long pBytesRead, long pContentLength, int pItems) {
        System.out.println((double)pBytesRead/pContentLength);
        session.setAttribute("progress", (double)pBytesRead/pContentLength);
    }
}
